const engineJsonTransform = {
  transform: (flowCode, sceneCode, version, config) => {
    let result = {
      flowCode: flowCode,
      sceneCode: sceneCode,
      version: version,
      nodes: [],
      edges: [],
    }
    let cells = config.cells
    for (let cell of cells) {
      if (cell['shape'] == 'edge') {
        result.edges.push(engineJsonTransform.createEdge(cell))
      } else {
        result.nodes.push(engineJsonTransform.createNode(cell))
      }
    }
    return result
  },
  createEdge (cell) {
    let edge = {}
    edge.id = cell.id
    edge.source = cell.source.cell
    edge.target = cell.target.cell
    return edge
  },
  createNode (cell) {
    let node = {}
    node = cell.data
    node.id = cell.id
    delete node.iconUrl
    return node
  }
}
export default engineJsonTransform
